/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPanelWord.java
 *
 * Created on Dec 4, 2011, 11:08:08 AM
 */
package recitation;

import java.awt.Dimension;
import target.Word;

/**
 *
 * @author buer
 */
public class JPanelWord extends javax.swing.JPanel {

    /** Creates new form JPanelWord */
    public JPanelWord(Word oneWord) {
        initComponents();

        setShowText(oneWord);
    }

    /**
     * 用于显示单词的方法，并设置该文本区域的读写性与单词一致
     * @param oneWord 
     */
    public void setShowText(Word oneWord) {
        //设置单词本体标签
        jLabel1.setText(oneWord.word);

        //显示单词的注释等其它信息
        jTAWord.append(oneWord.content);
        jTAWord.setEditable(false);
    }

    //返回文本框中的内容，用于保存编辑完成后的单词。
    public String getShowText() {
        return jTAWord.getText();
    }
    
    public void updateContent(Word word) {
        jLabel1.setText(word.word);
        jTAWord.setText(word.content);
    }
    
    /**
     * 设置文本框的可编辑行
     * @param flag 
     */
    public void setEditable(boolean flag) {
        jTAWord.setEditable(flag);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTAWord = new javax.swing.JTextArea();

        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jLabel1.setText("显示单词");
        jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jScrollPane1.setToolTipText("");

        jTAWord.setColumns(20);
        jTAWord.setRows(5);
        jScrollPane1.setViewportView(jTAWord);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 378, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTAWord;
    // End of variables declaration//GEN-END:variables
}
